package emergency;

public class StateRecorded extends State {

	/**
	 * Method for cancelling the given emergency
	 * 
	 * @post units of the given emergency are revoked
	 * 
	 * @post the state is set to canceled
	 */
	@Override
	public void cancel(Emergency e) throws IllegalStateException {
		e.revokeUnits(); 
		e.setState(new StateCanceled());
	}

	/**
	 * Method for competing the given emergency
	 * 
	 * @throws IllegalStateException, can't complete emergency in recorded state 
	 */
	@Override
	public void complete(Emergency e) throws IllegalStateException {
		throw new IllegalStateException("The emergency at place " + e.getLocation().toString() + " is recorded, first send units");
	}

	/**
	 * Method for sending units to the given emergency
	 * 
	 * @post unit of the emergency are moved to the emergency location
	 * 
	 * @post state is changed into inprogress
	 */
	@Override
	public void sendUnits(Emergency e) throws IllegalStateException {
		e.setState(new StateInProgress());
		e.moveUnits();
	}
	
	/**
	 * Method for getting a string representation of this concrete state
	 * 
	 * @return Returns a string representation of this concrete state
	 */
	@Override
	public String toString() {
		return("staterecorded");
	}

}
